<script>
$(document).ready(function() { 
    var options = { 
    	dataType: 'json', 
        beforeSubmit:  function (formData, jqForm, options){
    					if (!$('#uploadfield').val()){
    						$('#uploaderrordetail').html('You have not selected any image!!');
    						return false;
    					}
    					return true;
    				}, 
        success: function(responseText, statusText){
    				if(responseText.success == 1){
    					tb_remove("tinyMCE.execCommand('insertimage', '"+responseText.k+"', '"+responseText.align+"')");
    				}
    			},
        clearForm:true
    };
   
    $('#imageuploadform').ajaxForm(options);
  
}); 
</script>
<div>
	<form id="imageuploadform" enctype="multipart/form-data" action='/admin/?a=uploadimage&t=upload' method='post'>
		<p>Please select the image to upload :</p>
		<p>
			<input type="file" id="uploadfield" name="pic"/>
		</p>
		<p id="uploaderrordetail" />
		<p>We support jpg, jpeg, png and gif format with file size less than 1 MiB</p>
		<div class='layoutwrapper'>
			<div class='textheader'>Select a layout</div>
			<div class='layoutlistwrapper'>
				<ul>
					<li class='image-left-align'>
						<input type="radio" name="imagealign" checked="yes" id="imagealignleft" value="left"/>
						<label for="imagealignleft">Left</label>
					</li>
					<li class='image-center-align'>
						<input type="radio" name="imagealign" id="imagealigncenter" value="center"/>
						<label for="imagealigncenter">Center</label>
					</li>
					<li class='image-right-align'>
						<input type="radio" name="imagealign" id="imagealignright" value="right"/>
						<label for="imagealignright">Right</label>
					</li>
				</ul>
			</div>
			<div class='scalewrapper'>
				<div class='textheader'>Image Size/ Scaling</div>
				<p>Images will be scaled preserving the aspect ratio so that the maximum dimension is 400x400 px</p>
				<!-- <div class=''>
					<ul>
						<li>
							<input type="radio" name="imagescale" id="imagescalenone" value="no"/>
							<label for="imagescalenone">Do not scale image</label>
						</li>
						<li>
							<input type="radio" name="imagescale" id="imagescaleyes" value="yes"/>
							<label for="imagescaleyes">Automatically scale image</label>
						</li>
					</ul>
				</div> -->
			</div>
		</div>
		<div class='uploa'>
			<input type="submit" id="imgu" value="Upload Image"/>
			<input type="button" value="Cancel" onclick="tb_remove();" />
		</div>
	</form>
</div>